package com.hxzy.jsp.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.hxzy.jsp.entity.User;

public class UserDAOImpl extends BaseDAO implements UserDAO {

	
	@Override
	public User find(long id) {
		Connection conn = open();
		User user = null;
		try {
			PreparedStatement stmt = conn.prepareStatement("SELECT * FROM user where id = ? LIMIT 1");
			stmt.setLong(1, id);
			ResultSet rs = stmt.executeQuery();
			while (rs.next()) {
				user = new User(rs.getLong("id"), rs.getString("username"), rs.getString("nickname"), null,
						rs.getLong("gmt_login"), User.USER);
			}
		} catch (SQLException e) {
			e.printStackTrace();
			return user;
		}
		return user;
	}

	

}

